package com.pet.system.constants;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import com.pet.framework.util.StringUtil;

public class Status {
	
	public static void main(String[] args){
	    System.out.print("jd".matches("a|jd"));
	}
	public static String options(String value,String type){
		StringBuffer sbuf=new StringBuffer();
		 if("order".equals(type)){
		    for(Entry<String, Order> en:Status.Order.statusMap.entrySet()){
		         sbuf.append("<option value=\""+en.getValue().status+"\" "+(StringUtil.equals(value, en.getValue().status)?"selected=\"selected\"":"")+">"+en.getValue().name+"</option>");	
		    }		    
		 }else if("shop".equals(type)){
			 for(Entry<String, ShopStatus> en:ShopStatus.statusMap.entrySet()){
		         sbuf.append("<option value=\""+en.getValue().status+"\" "+(StringUtil.equals(value, en.getValue().status)?"selected=\"selected\"":"")+">"+en.getValue().name+"</option>");	
		    } 
		 }else if("channel".equals(type)){
			 for(Entry<String, Channel> en:Channel.statusMap.entrySet()){
		         sbuf.append("<option value=\""+en.getValue().status+"\" "+(StringUtil.equals(value, en.getValue().status)?"selected=\"selected\"":"")+">"+en.getValue().name+"</option>");	
		    } 
		 }else if("shopAccount".equals(type)){
			 for(Entry<String, ShopAccount> en:ShopAccount.statusMap.entrySet()){
		         sbuf.append("<option value=\""+en.getValue().status+"\" "+(StringUtil.equals(value, en.getValue().status)?"selected=\"selected\"":"")+">"+en.getValue().name+"</option>");	
		    } 
		 }
		 return sbuf.toString();
	}
	public static String radioCheck(String value,String type,String name){
		StringBuffer sbuf=new StringBuffer();
		sbuf.append("<input type='radio' name="+name+" value='' "+(StringUtil.isEmpty(value)?"checked='checked'":"")+" /> 所有");
		 if("order".equals(type)){
		    for(Entry<String, Order> en:Status.Order.statusMap.entrySet()){
		        sbuf.append(" <input type='radio' name="+name+" value='"+en.getValue().status+"' "+(StringUtil.equals(value, en.getValue().status)?"checked='checked'":"")+" />"+en.getValue().name); 
		    }		    
		 }else if("shop".equals(type)){
			 for(Entry<String, ShopStatus> en:ShopStatus.statusMap.entrySet()){
			     sbuf.append(en.getValue().name+" <input type='radio' name="+name+" value='"+en.getValue().status+"' "+(StringUtil.equals(value, en.getValue().status)?"checked='checked'":"")+"/>"+en.getValue().name); 
		    } 
		 }
		 return sbuf.toString();
	}
	
	public static String checkboxCheck(String value,String type,String name){
		StringBuffer sbuf=new StringBuffer();
		if("channel".equals(type)){
			for(Entry<String, Channel> en:Status.Channel.statusMap.entrySet()){
		        sbuf.append(" <input type='checkbox' name="+name+" value='"+en.getValue().status+"' "+( en.getValue().status.matches(value)?"checked='checked'":"")+" />"+en.getValue().name); 
		    }	
		}
		return sbuf.toString();
	}
	
	public static String toName(String value,String type){
		if("account".equals(type)){
			return Account.valueToName(value);
		}else if("order".equals(type)){
			return Order.valueToName(value);
		}else if("shop".equals(type)){
			return ShopStatus.valueToHtmlName(value);
		}else if("channel".equals(type)){
			return Channel.valueToName(value);
		}else if("balance".equals(type)){
			return Balance.valueToName(value);
		}
		return "none";
	}
	
	
	public static enum Account {
	        NORMAL("normal","正常"),
	        DROP("drop","删除");
	        private String status,name;
	        public static final Map<String, Account> statusMap = new HashMap<String, Account>();
			static {
				Account[] statu = Account.class.getEnumConstants();
			    for(Account s:statu ) {
			    	statusMap.put(s.status.toString(), s);
			    }
		    }
	        private Account(String status,String name) {
	            this.status = status;
	            this.name=name;
	        }
	        public String toString(){
	        	return this.status;
	        }
	        public String toName(){
	        	return this.name;
	        }
	        public static Account fromValue(String value) {
			    return statusMap.get(value);
		    }
	        public static String valueToName(String value){
	  		  Account s = Account.fromValue(value);
	  		  return null==s?value:s.toName();
	  	    }
	    }
	
   public static enum PayStatus { no,yes,cancel}
   public static enum Product {
        NORMAL("normal"),
        DROP("drop");
        private String status;
        public static final Map<String, Product> statusMap = new HashMap<String, Product>();
		static {
			Product[] statu = Product.class.getEnumConstants();
		    for(Product s:statu ) {
		    	statusMap.put(s.status.toString(), s);
		    }
	    }
        private Product(String status) {
            this.status = status;
        }
        public String toString(){
        	return this.status;
        }
    }
   
   public static enum Order {
       AUDITING("auditing","待确认"),
       INVALID("invalid","无效"),
       COMPETING("competing","竞标中"),
       DEAL("deal","制作中"),
       DELIVERING("delivering","配送中"),
       DONE("done","完成"),
       CANCELED("canceled","取消"),
       PUBLISHED("published","已发布");
       private String status,name;
       public static final Map<String, Order> statusMap = new HashMap<String, Order>();
		static {
			Order[] statu = Order.class.getEnumConstants();
		    for(Order s:statu ) {
		    	statusMap.put(s.status.toString(), s);
		    }
	    }
       private Order(String status,String name) {
           this.status = status;
           this.name=name;
       }
       public String toString(){
       	return this.status;
       }
       public String toName(){
       	return this.name;
       }
       public static Order fromValue(String value) {
		    return statusMap.get(value);
	    }
       public static String valueToName(String value){
    	   Order s = Order.fromValue(value);
 		  return null==s?value:s.toName();
 	    }
   }
   public static enum ShopStatus {
	   NEEDAPPROVING("needApproving","未认证","<span style='color:#ff6666'>未认证</span>"),
       APPROVED("approved","已认证","<span style='color:green;'>已认证</span>");
       private String status,name,htmlName;
       public static final Map<String, ShopStatus> statusMap = new HashMap<String, ShopStatus>();
		static {
			ShopStatus[] statu = ShopStatus.class.getEnumConstants();
		    for(ShopStatus s:statu ) {
		    	statusMap.put(s.status, s);
		    }
	    }
       private ShopStatus(String status,String name,String htmlName) {
           this.status = status;
           this.name=name;
           this.htmlName=htmlName;
       }
       public String toString(){
       	return this.status;
       }
       public String toName(){
       	return this.name;
       }
       public String toHtmlName(){
    	   return this.htmlName;
       }
       public static ShopStatus fromValue(String value) {
		    return statusMap.get(value);
	    }
       public static String valueToName(String value){
    	   ShopStatus s = ShopStatus.fromValue(value);
 		  return null==s?value:s.toName();
 	    }
       public static String valueToHtmlName(String value){
    	   ShopStatus s = ShopStatus.fromValue(value);
 		  return null==s?value:s.toHtmlName();
 	    }
   }
   
   public enum Channel {
	    JD("jd","京东"),
	    MEITUAN("meituan","美团"),
	    LASHOU("lashou","拉手"),
	    DIANPING("dianping","大众点评"),
	    NUOMI("nuomi","糯米"),
	    TIANMAO("tianmao","天猫"),
	    TAOBAO("taobao","淘宝");
	    private String status,name;
	    public static final Map<String, Channel> statusMap = new HashMap<String, Channel>();
		static {
			Channel[] statu = Channel.class.getEnumConstants();
		    for(Channel s:statu ) {
		    	statusMap.put(s.status.toString(), s);
		    }
	    }
	    private Channel(String status,String name) {
	        this.status = status;
	        this.name=name;
	    }
	    public String toString(){
	    	return this.status;
	    }
	    public String toName(){
	    	return this.name;
	    }
	    public static Channel fromValue(String value) {
		    return statusMap.get(value);
	    }
	    public static String valueToName(String value){
	    	Channel s = Channel.fromValue(value);
			  return null==s?value:s.toName();
		}
	}
   
   public enum ShopAccount {
	    shop15652928043("hua1000pass=3E9AC920E12B0FD547F0BD065C115ED55A7D2B4E356EBFA7F981DEDA6102CD98","15652928043 西二旗鲜花店"),
	    shop18611995275("hua1000pass=4F65AE16BCA8BB98FF1712916CA81621EBC76E2978D00B70515FFE5AF2AC4A35","18611995275 潘多拉花仙坊 ");
	    
	    private String status,name;
	    public static final Map<String, ShopAccount> statusMap = new HashMap<String, ShopAccount>();
		static {
			ShopAccount[] statu = ShopAccount.class.getEnumConstants();
		    for(ShopAccount s:statu ) {
		    	statusMap.put(s.status.toString(), s);
		    }
	    }
	    private ShopAccount(String status,String name) {
	        this.status = status;
	        this.name=name;
	    }
	    public String toString(){
	    	return this.status;
	    }
	    public String toName(){
	    	return this.name;
	    }
	    public static ShopAccount fromValue(String value) {
		    return statusMap.get(value);
	    }
	    public static String valueToName(String value){
	    	Channel s = Channel.fromValue(value);
			  return null==s?value:s.toName();
		}
	}
   public enum Balance {
	    state_new("new","对账中"),
	    state_check("check","对账完成 ");
	    private String status,name;
	    public static final Map<String, Balance> statusMap = new HashMap<String, Balance>();
		static {
			Balance[] statu = Balance.class.getEnumConstants();
		    for(Balance s:statu ) {
		    	statusMap.put(s.status.toString(), s);
		    }
	    }
	    private Balance(String status,String name) {
	        this.status = status;
	        this.name=name;
	    }
	    public String toString(){
	    	return this.status;
	    }
	    public String toName(){
	    	return this.name;
	    }
	    public static Balance fromValue(String value) {
		    return statusMap.get(value);
	    }
	    public static String valueToName(String value){
	    	Balance s = Balance.fromValue(value);
			  return null==s?value:s.toName();
		}
	}
   public enum Code{order} 
}
